//
//  HomeModel.swift
//  XQDBDemo
//
//  Created by WXQ on 2021/3/10.
//

import Foundation
import XQWCDB
import WCDBSwift

class HomeModel: NSObject, WCDBSwift.TableCodable, XQWCDBModelConvenientProtocol {
    
    static var xq_table: String = "home"
    
    var homeId: String = UUID().uuidString
    
    @objc var name: String? = ""
    
    var createDate = Date()
    
    var peopleArr = [PeopleModel]()
    
    /// 变成json存到数据库
    var jsonModel: OtherDataModel?
    
    enum CodingKeys: String, CodingTableKey {
        
        typealias Root = HomeModel

        //List the properties which should be bound to table
        case homeId
        case name
        case createDate
        case jsonModel
        
        static let objectRelationalMapping = TableBinding(CodingKeys.self)
        
//        static var columnConstraintBindings: [CodingKeys: ColumnConstraintBinding]? {
//            return [
//                // 作为主键
//                homeId: ColumnConstraintBinding(isPrimary: true),
//                // 不能为空的意思
////                createDate: ColumnConstraintBinding.init(isNotNull: true, defaultTo: Date())
//            ]
//        }
        
    }
    
    struct OtherDataModel: ColumnJSONCodable {
        
        var price: Float = 0
        
        var sizeStr: String = ""
        
    }
    
    
}






